home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1989 January & February / rerun-1989-01-02.d64 / chummy checkers (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  4KB  |  172 lines

  1. 100 rem---checkers
  2. 110 poke52,56:poke56,56:clr
  3. 120 gosub1580
  4. 130 v=53248:s1=54272:s2=s1+7:sc=1024:tc=646:a=rnd(-ti)
  5. 140 fora=1to38:sp$=sp$+chr$(32):next
  6. 150 dim bd(63),ch(1),mv$(1),d(1,3),tl(1),pl(1)
  7. 160 forz=0to63:bd(z)=sc+168+int(z/8)*80+(zand7)*3:next
  8. 170 ch(0)=163:ch(1)=171
  9. 180 mv$(0)=left$(sp$,4):mv$(1)="move"
  10. 190 d(0,0)=7:d(0,1)=9:d(0,2)=-7:d(0,3)=-9
  11. 200 fora=0to3:d(1,a)=-d(0,a):next
  12. 210 pokev+39,7:pokev+40,2
  13. 220 poke2040,13:poke2041,14
  14. 230 fora=s1tos1+24:pokea,0:next
  15. 240 pokes1+1,37:pokes1+5,9
  16. 250 pokes2+1,5:pokes2+5,8:pokes2+6,240:pokes1+24,15
  17. 260 gosub1110
  18. 270 p1=0
  19. 280 rem---main
  20. 290 p2=p1:p1=1-p1:m=0
  21. 300 cy=10:cx=2:gosub1490:poketc,1:printmv$(p1)
  22. 310 cx=34:gosub1490:poketc,0:printmv$(p2)
  23. 320 ifpl(p1)then440
  24. 330 rem---computer
  25. 340 m1=1:forzz=0to63
  26. 350 ifpeek(bd(zz))=ch(p1)thengosub930
  27. 360 next:ifm1=1then680
  28. 370 ifm1<6thengosub860:goto410
  29. 380 gosub820:iftl(p2)=0then680
  30. 390 m1=1:zz=qd:gosub930
  31. 400 ifm1>=6then380
  32. 410 geta$:ifa$=chr$(133)then680
  33. 420 goto290
  34. 430 rem---player
  35. 440 r=p1*7:c=r:pokev+3,0
  36. 450 gosub720:ifa$=chr$(133)then680
  37. 460 ifpeek(l)<>ch(p1)then450
  38. 470 k=-(peek(l+1)=166)
  39. 480 pokev+2,peek(v):pokev+16,(peek(v+16)and1)*3:pokev+3,peek(v+1)
  40. 490 rf=r:cf=c:lf=l
  41. 500 gosub720:ifa$=chr$(133)then680
  42. 510 rem---test
  43. 520 ifr=rfandc=cfthen500
  44. 530 ifpeek(l)<>160then620
  45. 540 rm=rf-r:cm=cf-c:ifabs(rm)<>abs(cm)then620
  46. 550 ifk=0andsgn(rm)<>sgn(p1-.5)then620
  47. 560 ifabs(rm)=1andm=0thengosub860:goto290
  48. 570 ifabs(rm)<>2then620
  49. 580 rj=rf-rm/2:cj=cf-cm/2
  50. 590 lj=bd(rj*8+cj)
  51. 600 ifpeek(lj)=ch(p2)then660
  52. 610 rem---illegal move
  53. 620 ifmthen290
  54. 630 pokes2+4,33:fora=1to200:next
  55. 640 pokes2+4,32:goto440
  56. 650 rem---jump checker
  57. 660 gosub820:iftl(p2)then480
  58. 670 rem---end of game
  59. 680 q$="play again? [y/n] ":se$="yn":gosub1350
  60. 690 ifa$="y"then260
  61. 700 poke832,0:sys832
  62. 710 rem---joystick
  63. 720 js=peek(56320)
  64. 730 geta$:ifa$=chr$(133)thenreturn
  65. 740 r=r+sgn(jsand1)-sgn(jsand2)and7
  66. 750 c=c+sgn(jsand4)-sgn(jsand8)and7
  67. 760 pokev,88+c*24and255:pokev+16,(peek(v+16)and2)-(c=7)
  68. 770 pokev+1,82+r*16
  69. 780 pokev+21,3:fora=1to90:next:pokev+21,0
  70. 790 ifjsand16then720
  71. 800 l=bd(r*8+c):return
  72. 810 rem---jump
  73. 820 fora=0to2
  74. 830 pokelj+a,160:pokelj+40+a,160:next
  75. 840 m=m+1:tl(p2)=tl(p2)-1:gosub1290
  76. 850 rem---move
  77. 860 forz=0to2:pokel+z+s1,p1:pokel+40+z+s1,p1
  78. 870 pokel+z,peek(lf+z):pokel+40+z,peek(lf+40+z)
  79. 880 pokelf+z,160:pokelf+40+z,160:next
  80. 890 ifr=7orr=0thenk=1:pokel+1,166:pokel+41,167
  81. 900 pokes1+4,16:pokes1+4,17
  82. 910 return
  83. 920 rem---find computer move
  84. 930 kd=-(peek(bd(zz)+1)=166)
  85. 940 fordr=0to1+kd*2:m0=0
  86. 950 d=zz+d(p1,dr):ifd<0ord>63then1090
  87. 960 f1=peek(bd(d)):f2=0:dj=d
  88. 970 d=d+d(p1,dr):ifd<0ord>63then990
  89. 980 f2=peek(bd(d))
  90. 990 iff1<>160then1040
  91. 1000 m0=2:d=dj:iff2<>ch(p2)thenm0=3
  92. 1010 iff2=ch(p1)thenm0=4
  93. 1020 if(d<8ord>55)andkd=0thenm0=5
  94. 1030 goto1070
  95. 1040 iff1<>ch(p2)orf2<>160then1090
  96. 1050 m0=6:ifpeek(bd(dj)+1)=166thenm0=7
  97. 1060 if(d<8ord>55)andkd=0thenm0=8
  98. 1070 m0=m0+rnd(1)
  99. 1080 ifm0>m1thenm1=m0:l=bd(d):lf=bd(zz):lj=bd(dj):r=int(d/8):qd=d
  100. 1090 next:return
  101. 1100 rem---screen
  102. 1110 pokev+21,0:printchr$(147):poketc,1
  103. 1120 printtab(15)" checkers ":zz=96
  104. 1130 fora=0to63:forz=0to2
  105. 1140 pokebd(a)+z,zz:pokebd(a)+40+z,zz
  106. 1150 next
  107. 1160 if(aand7)<7thenzz=160+(zz=160)*64
  108. 1170 next
  109. 1180 poketc,0:a$="#"
  110. 1190 fora=1to3:gosub1520:next
  111. 1200 poketc,1:a$="+"
  112. 1210 fora=6to8:gosub1520:next
  113. 1220 rem---get players
  114. 1230 q$="players [0,1 or 2] ":se$="012":gosub1350
  115. 1240 pl(0)=0:pl(1)=0:a=val(a$)
  116. 1250 ifathenpl(1)=1:pl(0)=a-1
  117. 1260 cy=22:cx=9:gosub1490:print"press  f1 [146] to end game"
  118. 1270 tl(0)=12:tl(1)=12
  119. 1280 rem---print totals
  120. 1290 cy=12:cx=3:a=1:gosub1310
  121. 1300 cx=35:a=0
  122. 1310 gosub1490:poketc,a
  123. 1320 printright$(str$(tl(a)),2)
  124. 1330 return
  125. 1340 rem---get key
  126. 1350 cy=22:gosub1460
  127. 1360 cx=(40-len(q$))/2:gosub1490
  128. 1370 poketc,1:printq$;
  129. 1380 poke198,0:poke204,0
  130. 1390 wait198,15:geta$:z=len(se$)
  131. 1400 ifa$=mid$(se$,z,1)then1430
  132. 1410 z=z-1:ifzthen1400
  133. 1420 goto1390
  134. 1430 poke204,1:printa$
  135. 1440 fora=1to500:next
  136. 1450 rem---clear line
  137. 1460 poke214,cy-1:print:printsp$
  138. 1470 return
  139. 1480 rem---plot
  140. 1490 poke214,cy-1:print:printtab(cx);
  141. 1500 return
  142. 1510 rem---print checkers
  143. 1520 cy=2+a*2:cx=8+(aand1)*3:gosub1490
  144. 1530 forz=0to3
  145. 1540 printchr$(18);a$;"$%[157][157][157]*)([145]";
  146. 1550 next
  147. 1560 return
  148. 1570 rem---initialize
  149. 1580 printchr$(8)chr$(147)
  150. 1590 poke56334,peek(56334)and254
  151. 1600 poke1,peek(1)and251
  152. 1610 fora=0to511:poke14336+a,peek(53248+a):next
  153. 1620 poke1,peek(1)or4
  154. 1630 poke56334,peek(56334)or1
  155. 1640 poke53272,(peek(53272)and240)or14
  156. 1650 fora=0to31:readz:poke14616+a,z:poke14616+63-a,z:next
  157. 1660 fora=0to7:poke14616+64+a,peek(14616+a):next
  158. 1670 poke53280,7:poke53281,15
  159. 1680 poke53282,10:poke53283,2
  160. 1690 poke53265,peek(53265)or64
  161. 1700 rem---sprite cursors
  162. 1710 fora=832to959:pokea,0:next
  163. 1720 fora=835to874step3:pokea,192:pokea+2,3:next
  164. 1730 fora=0to2:poke832+a,255:poke877+a,255:next
  165. 1740 fora=896to943:pokea,255:next
  166. 1750 return
  167. 1760 rem---character data
  168. 1770 data0,0,0,3,7,15,15,31
  169. 1780 data0,0,255,255,255,255,255,255
  170. 1790 data0,0,0,192,224,240,240,248
  171. 1800 data0,0,255,255,255,153,147,135
  172.